
module;
#include <napi.h>
module exports:test;

namespace yichu {

    MyClass::MyClass(const Napi::CallbackInfo& info) : Napi::ObjectWrap<MyClass>(info)
    {

        info.Env().RunScript("console.log('aaaa')"); 
    }

    MyClass::MyClass(const Napi::CallbackInfo& info,int a) : Napi::ObjectWrap<MyClass>(info)
    {
        info.Env().RunScript("console.log('cccc')");
    }

    Napi::Value MyClass::Hello(const Napi::CallbackInfo& info)
    {
        Napi::Env env = info.Env();
        return Napi::String::New(env, "Hello from C++!");
    }
    Napi::Object MyClass::Init(Napi::Env env, Napi::Object exports)
    {
        Napi::HandleScope scope(env);

        Napi::Function func = DefineClass(env, "MyClass", {InstanceMethod("hello", &MyClass::Hello)});

        constructor = Napi::Persistent(func);
        constructor.SuppressDestruct();

        exports.Set("MyClass", func);
        return exports;
    }
}
